<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>作用域插槽的案例</title>
</head>
<body>
<div id="app">
  <cpn>
    <div slot="languages" slot-scope="slot">
      <!--<span v-for="item in slot.data">{{item}} * </span><br>-->
      <span>{{slot.data.join(' * ')}}</span>
    </div>
  </cpn>
  <hr>
  <cpn>
    <div  slot="msg" slot-scope="slot">
      <input type="text" :value="slot.data">
    </div>
  </cpn>
</div>
<template id="cpn">
  <div>
    <slot name="languages" :data="pLanguages">
      <ul>
        <li v-for="item in pLanguages">{{item}}</li>
      </ul>
    </slot>
    <slot name="msg" :data="msg">
      <span>{{msg}}</span>
    </slot>
  </div>
</template>

<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: 'Hello Vue'
    },
    components: {
      cpn: {
        template: '#cpn',
        data() {
          return {
            pLanguages: ['JavaScript', 'C++', 'Java', 'C#', 'Python', 'Go', 'Swift'],
            msg:"子组件信息"
          }
        }
      }
    }
  });
</script>
</body>
</html>
